package com.wandian.weather.mvvm.nl;

import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.haibin.calendarview.CalendarView;
import com.mylib.libcore.config.RouterConfig;
import com.mylib.libcore.mvvm.BaseMVVMActivity;
import com.mylib.libcore.utils.JsonUtil;
import com.mylib.libcore.utils.UIUtils;
import com.wandian.weather.R;
import com.wandian.weather.bean.HolidayEntity;
import com.wandian.weather.bean.ModernTextBean;
import com.wandian.weather.databinding.WeatherActivityWatherNlBinding;
import com.wandian.weather.dialog.SelectDateDialog;
import com.wandian.weather.tools.CalendarUtil;
import com.wandian.weather.tools.Lunar;
import com.wandian.weather.tools.wnl.CalendarBean;
import com.wandian.weather.tools.wnl.LunarCalendar;
import com.wandian.weather.view.HorizontalDividerItemDecoration;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.MultiItemTypeAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;

/**
 * @author Administrator
 * @date 2019/12/18-14:28
 * @description 农历
 **/
@Route(path = RouterConfig.ROUTER_ACTIVITY_WEATHER_NL)
public class WeatherNLActivity extends BaseMVVMActivity<WeatherNLViewModel> implements  SelectDateDialog.onSelectDate,  CalendarView.OnCalendarSelectListener{
    private WeatherActivityWatherNlBinding dataBinding;

    private LunarCalendar lunarCalendar = new LunarCalendar();
    private CalendarUtil util;
    private Calendar calendar;

    private Calendar calDay;
    private HashMap<String, String> shichenTable = new HashMap<>();
    private CommonAdapter mAdapter;
    private CalendarBean info;
    private Calendar mcCalendar;
    private List<HashMap<String, String>> hourYjList = new ArrayList<HashMap<String, String>>();
    private ArrayList<ModernTextBean> listModernTextEntities = new ArrayList<>();
    private ArrayList<String> listModernTextStr = new ArrayList<>();
    @Override
    public void init(Bundle savedInstanceState) {
        dataBinding = DataBindingUtil.setContentView(this, R.layout.weather_activity_wather_nl);
        dataBinding.setLifecycleOwner(this);
        dataBinding.setViewModel(mViewModel);

        initClink();
        initRecycle();
        initViewData();
    }


    private void initViewData(){
        dataBinding.toolBarTvTitle.setText("农历");

        try {
            calendar = Calendar.getInstance();
            dataBinding.calendarView.setWeekStarWithMon();

            dataBinding.calendarView.setOnMonthChangeListener(new CalendarView.OnMonthChangeListener() {
                @Override
                public void onMonthChange(int year, int month) {
                    dataBinding.toolBarTvTitle.setText(year + "年" + month + "月");
                }
            });

            dataBinding.calendarView.setOnCalendarSelectListener(this);

            int year = calendar.get(Calendar.YEAR);
            int month = calendar.get(Calendar.MONTH) + 1;
            dataBinding.toolBarTvTitle.setText(year + "年" + month + "月");

            setlunarDate(calendar);


            util = new CalendarUtil(calendar);
            getYiJiData(calendar);
         //   getYiJiDataServer(calendar);
            mViewModel.getJijiari();

            initOldCalendarData();

        } catch (Exception e) {
            e.printStackTrace();
        }

        mViewModel.listHoliday.observe(this,holidayEntityList->{
            if(!UIUtils.isEmpty(holidayEntityList) && holidayEntityList.size()>0){
                try {
                    HashMap<String, com.haibin.calendarview.Calendar> map = new HashMap<>();
                    for (HolidayEntity he : holidayEntityList) {
                        try {
                            for (String date : he.getFjtime()) {
                                String[] dateStr = date.split("-");
                                if(dateStr==null || dateStr.length==0) continue;
                                com.haibin.calendarview.Calendar c1 = new com.haibin.calendarview.Calendar();
                                c1.setYear(Integer.parseInt(dateStr[0]));
                                c1.setMonth(Integer.parseInt(dateStr[1]));
                                c1.setDay(Integer.parseInt(dateStr[2]));
                                c1.setSchemeColor(Color.parseColor("#FFEA00"));//如果单独标记颜色、则会使用这个颜色
                                c1.setScheme("假");
                                map.put(c1.toString(), c1);
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }

                        try {
                            if(he.getBxtime()==null || he.getBxtime().size()==0) return;
                            for (String date : he.getBxtime()) {
                                String[] dateStr = date.split("-");
                                if(dateStr==null || dateStr.length==0) continue;
                                com.haibin.calendarview.Calendar c1 = new com.haibin.calendarview.Calendar();
                                c1.setYear(Integer.parseInt(dateStr[0]));
                                c1.setMonth(Integer.parseInt(dateStr[1]));
                                c1.setDay(Integer.parseInt(dateStr[2]));
                                c1.setSchemeColor(Color.parseColor("#FF485B"));//如果单独标记颜色、则会使用这个颜色
                                c1.setScheme("班");
                                map.put(c1.toString(), c1);
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                    dataBinding.calendarView.setSchemeDate(map);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }



    private void initRecycle(){


    }
    private void initClink(){
        dataBinding.toolBarIvBack.setOnClickListener(v -> finish());

        //现代文
        dataBinding.toolBarTvRight.setOnClickListener(v -> {
            if (info == null)
                return;
            try {
                startCkxdw(dataBinding.toolBarTvRight.getId());
            } catch (Exception e) {
                e.printStackTrace();
            }
        });

        //其他日期
        dataBinding.toolBarTvTitle.setOnClickListener(v -> {
            SelectDateDialog sdd = new SelectDateDialog(this);
            sdd.setOnSelectDate(this);
            sdd.showDialog();
        });
        dataBinding.imgSelDate.setOnClickListener(v -> {
            SelectDateDialog sdd = new SelectDateDialog(this);
            sdd.setOnSelectDate(this);
            sdd.showDialog();
        });

    }

    private void initOldCalendarData(){
        initData();
        final GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 6) {
            @Override
            public boolean canScrollVertically() {//禁止滑动事件
                return false;
            }
        };

        dataBinding.scyjView.setLayoutManager(gridLayoutManager);
        dataBinding.scyjView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(this)
                .color(getResources().getColor(R.color.translucent_bg))
                .size(4)
                .build());

        setScyjAdapter();
        requestCalendar();
    }

    private void setlunarDate(Calendar c) {
        try {
            Lunar lunar = new Lunar(c);
            dataBinding.tvLunarDate.setText(lunar.getlunarMonth()+lunar.getlunarDay());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void getYiJiData(Calendar calDay) {
        try {
            HashMap<String, Object> map = lunarCalendar.getBaseInfo(calDay.get(Calendar.YEAR), (calDay.get(Calendar.MONTH) + 1), calDay.get(Calendar.DATE));
            String jsonString = JsonUtil.toJson(map);
            JSONObject jsonObject = new JSONObject(jsonString);
            if(UIUtils.isEmpty(jsonObject))return;
            String yi = jsonObject.getJSONObject("yiji").getString("yi");
            String ji = jsonObject.getJSONObject("yiji").getString("ji");
            String oldMonth = jsonObject.getJSONObject("oldtime").getString("month");
            String oldDay = jsonObject.getJSONObject("oldtime").getString("day");
            dataBinding.yiText.setText(yi+"");
            dataBinding.jiText.setText(ji+"");

            int week = calDay.get(Calendar.WEEK_OF_YEAR);
            String weekNum = "第" + week + "周";
            dataBinding.tvYmdWeek.setText(weekNum + "  " + util.cyclical() + "[" + util.animalsYear() + "]年 " + oldMonth + "月  " + oldDay + "日");

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    // 默认数据
    private void initData() {
        shichenTable.put("子", "23时-1时");
        shichenTable.put("丑", "1时-3时");
        shichenTable.put("寅", "3时-5时");
        shichenTable.put("卯", "5时-7时");
        shichenTable.put("辰", "7时-9时");
        shichenTable.put("巳", "9时-11时");
        shichenTable.put("午", "11时-13时");
        shichenTable.put("未", "13时-15时");
        shichenTable.put("申", "15时-17时");
        shichenTable.put("酉", "17时-19时");
        shichenTable.put("戌", "19时-21时");
        shichenTable.put("亥", "21时-23时");
        calDay = Calendar.getInstance();//今天的日期
    }


    private void setScyjAdapter() {
        mAdapter = new CommonAdapter<HashMap<String, String>>(this, R.layout.weather_item_hour_yj_item_layout, hourYjList) {
            @Override
            protected void convert(ViewHolder holder, HashMap<String, String> o, int position) {
                TextView hourJi = holder.getView(R.id.hour_ji_text);//显示时辰吉

                TextView hourXiong = holder.getView(R.id.hour_xiong_text);//显示时辰凶


                if ("吉".equals(o.get("xiongji"))) {
                    hourXiong.setVisibility(View.GONE);
                    hourJi.setVisibility(View.VISIBLE);
                } else {
                    hourXiong.setVisibility(View.VISIBLE);
                    hourJi.setVisibility(View.GONE);
                }

                holder.setText(R.id.old_hour_text, o.get("shichen"));
                holder.setText(R.id.new_hour_text, shichenTable.get(o.get("shichen").substring(1)));
            }

        };
        dataBinding.scyjView.setAdapter(mAdapter);
        mAdapter.notifyDataSetChanged();
        mAdapter.setOnItemClickListener(new MultiItemTypeAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View view, RecyclerView.ViewHolder holder, int position) {
//                ActivityJump.startSCYJ(calDay, mContext);
            }

            @Override
            public boolean onItemLongClick(View view, RecyclerView.ViewHolder holder, int position) {
                return false;
            }
        });
    }

    /**
     * 得到日历数据
     */
    private void requestCalendar() {
        if (mcCalendar == null) {
            mcCalendar =  Calendar.getInstance();
        }
        try {
            HashMap<String, Object> map = lunarCalendar.getBaseInfo(calDay.get(Calendar.YEAR), (calDay.get(Calendar.MONTH) + 1), calDay.get(Calendar.DATE));
            String jsonString = JsonUtil.toJson(map);
            JSONObject jsonObject = new JSONObject(jsonString);
            if(UIUtils.isEmpty(jsonObject))return;
            parseData(jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 解析数据
     *
     * @param obj
     */
    private void parseData(JSONObject obj)  {

        //
        info = new CalendarBean();
        try {
            info.setCaishen(obj.getString("caishen"));
            info.setChongsha(obj.getJSONObject("chongsha").getString("chongsha"));
            info.setFushen(obj.getString("fushen"));
            info.setMinglu(obj.getString("minglu"));
            info.setXishen(obj.getString("xishen"));
            info.setPengzhu(obj.getJSONObject("pengzhu").getString("pengzhu"));
            //
            List<HashMap<String, String>> modern_pengzhu = new ArrayList<HashMap<String, String>>();
            JSONArray array = obj.getJSONObject("pengzhu").getJSONArray("modern_pengzhu");
            for (int i = 0; i < array.length(); i++) {
                HashMap<String, String> map = new HashMap<String, String>();
                map.put("title", array.getJSONObject(i).getString("title"));
                modern_pengzhu.add(map);
            }
            info.setPengzhu_modern(modern_pengzhu);

            //
            List<HashMap<String, String>> modern_chongsha = new ArrayList<HashMap<String, String>>();
            array = obj.getJSONObject("chongsha").getJSONArray("modern_chongsha");
            for (int i = 0; i < array.length(); i++) {
                HashMap<String, String> map = new HashMap<String, String>();
                map.put("title", array.getJSONObject(i).getString("title"));
                modern_chongsha.add(map);
            }
            info.setChongsha_modern(modern_chongsha);
            //
            List<HashMap<String, String>> shichen = new ArrayList<HashMap<String, String>>();
            JSONArray arrayShichen = obj.getJSONArray("shichen");
            for (int i = 0; i < arrayShichen.length(); i++) {
                HashMap<String, String> map = new HashMap<String, String>();
                map.put("shichen", arrayShichen.getJSONObject(i).getString("shichen"));
                map.put("xiongji", arrayShichen.getJSONObject(i).getString("xiongji"));
                shichen.add(map);
            }
            info.setShichen(shichen);
            hourYjList.clear();
            hourYjList.addAll(shichen);
            mAdapter.notifyDataSetChanged();
        }catch (Exception e){

        }


        //
        HashMap<String, String> childofGod = new HashMap<String, String>();
        try {
            childofGod.put(CalendarBean.KEY_CLASSICAL_CHINESE, obj.getJSONObject("childofGod").getString("taishen"));
            childofGod.put(CalendarBean.KEY_MODERN_TEXT, obj.getJSONObject("childofGod").getString("modern_taishen"));
            info.setChildofGod(childofGod);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        //
        HashMap<String, String> zhishen = new HashMap<String, String>();
        try {
            zhishen.put(CalendarBean.KEY_CLASSICAL_CHINESE, obj.getJSONObject("zhishen").getString("zhishen"));
            zhishen.put(CalendarBean.KEY_MODERN_TEXT, obj.getJSONObject("zhishen").getString("modern_zhishen"));
            info.setZhishen(zhishen);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        //
        HashMap<String, String> wuxing = new HashMap<String, String>();
        try {
            wuxing.put(CalendarBean.KEY_CLASSICAL_CHINESE, obj.getJSONObject("wuxing").getString("wx"));
            wuxing.put(CalendarBean.KEY_MODERN_TEXT, obj.getJSONObject("wuxing").getString("modern_wuxing"));
            info.setWuxing(wuxing);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        //
        HashMap<String, String> jianchuri = new HashMap<String, String>();
        try {
            jianchuri.put(CalendarBean.KEY_CLASSICAL_CHINESE, obj.getJSONObject("jianchuri").getString("jianchuri"));
            jianchuri.put(CalendarBean.KEY_MODERN_TEXT, obj.getJSONObject("jianchuri").getString("modern_jianchuri"));
            info.setJianchuri(jianchuri);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        //
        HashMap<String, String> xingxiu = new HashMap<String, String>();
        try {
            xingxiu.put(CalendarBean.KEY_CLASSICAL_CHINESE, obj.getJSONObject("xingxiu").getString("xingxiu"));
            xingxiu.put(CalendarBean.KEY_MODERN_TEXT, obj.getJSONObject("xingxiu").getString("modern_xingxiu"));
            info.setXingxiu(xingxiu);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        //
        HashMap<String, String> yiji = new HashMap<String, String>();
        try {
            yiji.put("yi", obj.getJSONObject("yiji").getString("yi"));
            yiji.put("ji", obj.getJSONObject("yiji").getString("ji"));
            info.setYiji(yiji);
            //
            List<HashMap<String, String>> modern_yi = new ArrayList<HashMap<String, String>>();
            JSONArray arrayModern_yi = obj.getJSONObject("yiji").getJSONArray("modern_yi");
            for (int i = 0; arrayModern_yi != null && i < arrayModern_yi.length(); i++) {
                HashMap<String, String> map = new HashMap<String, String>();
                map.put("title", arrayModern_yi.getJSONObject(i).getString("title"));
                map.put("describe", arrayModern_yi.getJSONObject(i).getString("describe"));
                modern_yi.add(map);
            }

            info.setYiji_yi(modern_yi);
            //
            List<HashMap<String, String>> modern_ji = new ArrayList<HashMap<String, String>>();
            JSONArray arrayModern_ji = obj.getJSONObject("yiji").getJSONArray("modern_ji");
            for (int i = 0;  arrayModern_ji != null && i < arrayModern_ji.length(); i++) {
                HashMap<String, String> map = new HashMap<String, String>();
                map.put("title", arrayModern_ji.getJSONObject(i).getString("title"));
                map.put("describe", arrayModern_ji.getJSONObject(i).getString("describe"));
                modern_ji.add(map);
            }
            info.setYiji_ji(modern_ji);
        }catch (Exception e){}

        //
        HashMap<String, String> oldtime = new HashMap<String, String>();
        try {
            oldtime.put("year", obj.getJSONObject("oldtime").getString("year")+"");
            oldtime.put("month", obj.getJSONObject("oldtime").getString("month")+"");
            oldtime.put("day", obj.getJSONObject("oldtime").getString("day")+"");
            oldtime.put("week", obj.getJSONObject("oldtime").getString("week")+"");
            info.setOldtime(oldtime);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HashMap<String, String> jishen = new HashMap<String, String>();
        try {
            jishen.put("jishen", obj.getJSONObject("shensha").getString("jishen"));
            jishen.put("xiongshen", obj.getJSONObject("shensha").getString("xiongshen"));
            info.setJishen(jishen);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        dataBinding.wuxingText.setText(info.getWuxing().get(CalendarBean.KEY_CLASSICAL_CHINESE));
        dataBinding.chongshaText.setText(info.getChongsha());
        dataBinding.zhishenText.setText(info.getZhishen().get(CalendarBean.KEY_CLASSICAL_CHINESE));
        dataBinding.pzbjText.setText(info.getPengzhu());
        dataBinding.jcsesText.setText(info.getJianchuri().get(CalendarBean.KEY_CLASSICAL_CHINESE));
        dataBinding.esbxxText.setText(info.getXingxiu().get(CalendarBean.KEY_CLASSICAL_CHINESE));
        dataBinding.jrtsText.setText(info.getChildofGod().get(CalendarBean.KEY_CLASSICAL_CHINESE));
        dataBinding.yiText.setText(info.getYiji().get("yi"));
        dataBinding.jiText.setText(info.getYiji().get("ji"));
        try {
            StringBuffer str = new StringBuffer();

            String jishengStr = info.getJishen().get("jishen");
            String jishenStr[] = (jishengStr != null ? jishengStr.split(" ") : null);
            for (int i = 0; jishenStr != null && i < jishenStr.length; i++) {
                HashMap<String, String> map = new HashMap<String, String>();
                str.append(jishenStr[i] + ((i % 2 == 1 && i != 0) ? "\n" : " "));
            }
            dataBinding.jsyqText.setText(str);
            str.setLength(0);
            //
            String xiongshenStr = info.getJishen().get("jishen");
            String xiongshenArray[] = (xiongshenStr != null ? xiongshenStr.split(" ") : null);
            for (int i = 0; xiongshenArray != null && i < xiongshenArray.length; i++) {
                HashMap<String, String> map = new HashMap<String, String>();
                str.append(xiongshenArray[i] + ((i % 2 == 1 && i != 0) ? "\n" : " "));
            }
            dataBinding.xsyjText.setText(str);
            str.setLength(0);
        }catch (Exception e){}

    }

    /***
     * 黄历现代文
     */
    private void startCkxdw(int id) {
        listModernTextEntities.clear();
        listModernTextStr.clear();
        //
        ModernTextBean item = new ModernTextBean();
        for (int j = 0; j < info.getYiji_yi().size(); j++) {
            HashMap<String, String> map = info.getYiji_yi().get(j);
            item.getItems().add(item.new ItemValue(map.get("title"), map.get("describe")));
        }
        for (int j = 0; j < info.getYiji_ji().size(); j++) {
            HashMap<String, String> map = info.getYiji_ji().get(j);
            item.getItems2().add(item.new ItemValue(map.get("title"), map.get("describe")));
        }
        listModernTextEntities.add(item);
        listModernTextStr.add("宜忌");

        //
        item = new ModernTextBean();
        item.getItems().add(item.new ItemValue(info.getWuxing().get(CalendarBean.KEY_CLASSICAL_CHINESE), info.getWuxing().get(CalendarBean.KEY_MODERN_TEXT)));
        listModernTextEntities.add(item);
        listModernTextStr.add("五行");
        //
        item = new ModernTextBean();
        for (int j = 0; j < info.getChongsha_modern().size(); j++) {
            HashMap<String, String> map = info.getChongsha_modern().get(j);
            item.getItems().add(item.new ItemValue("", map.get("title")));
        }
        listModernTextEntities.add(item);
        listModernTextStr.add("冲煞");
        //
        item = new ModernTextBean();
        item.getItems().add(item.new ItemValue(info.getZhishen().get(CalendarBean.KEY_CLASSICAL_CHINESE), info.getZhishen().get(CalendarBean.KEY_MODERN_TEXT)));
        listModernTextEntities.add(item);
        listModernTextStr.add("值神");

        //
        try {
            item = new ModernTextBean();
            item.getItems().add(item.new ItemValue("", info.getJishen().get("jishen")));
            listModernTextEntities.add(item);
            listModernTextStr.add("吉神");
        }catch (Exception e){

        }

        //
        item = new ModernTextBean();
        item.getItems().add(item.new ItemValue(info.getChildofGod().get(CalendarBean.KEY_CLASSICAL_CHINESE), info.getChildofGod().get(CalendarBean.KEY_MODERN_TEXT)));
        listModernTextEntities.add(item);
        listModernTextStr.add("胎神");

        //
       try {
          item = new ModernTextBean();
          item.getItems().add(item.new ItemValue("", info.getJishen().get("xiongshen")));
          listModernTextEntities.add(item);
          listModernTextStr.add("凶神");
       }catch(Exception e){}

        //
        item = new ModernTextBean();
        item.getItems().add(item.new ItemValue(info.getJianchuri().get(CalendarBean.KEY_CLASSICAL_CHINESE), info.getJianchuri().get(CalendarBean.KEY_MODERN_TEXT)));
        listModernTextEntities.add(item);
        listModernTextStr.add("建除");

        //
        item = new ModernTextBean();
        item.getItems().add(item.new ItemValue(info.getXingxiu().get(CalendarBean.KEY_CLASSICAL_CHINESE), info.getXingxiu().get(CalendarBean.KEY_MODERN_TEXT)));
        listModernTextEntities.add(item);
        listModernTextStr.add("星宿");

        //
        item = new ModernTextBean();
        for (int j = 0; j < info.getPengzhu_modern().size(); j++) {
            HashMap<String, String> map = info.getPengzhu_modern().get(j);
            String array[] = map.get("title").split("：");
            item.getItems().add(item.new ItemValue(array.length > 0 ? array[0] : "", array.length > 0 ? array[1] : array[0]));
        }
        listModernTextEntities.add(item);
        listModernTextStr.add("彭祖");

        int selId = 0;
        if (id == R.id.yi_ji_layout) {
            selId = 0;
        } else if (id == R.id.lly_wuxing) {
            selId = 1;
        } else if (id == R.id.lly_chongsha) {
            selId = 2;
        } else if (id == R.id.lly_zhisheng) {
            selId = 3;
        } else if (id == R.id.lly_jisheng) {
            selId = 4;
        } else if (id == R.id.lly_taisheng) {
            selId = 5;
        } else if (id == R.id.lly_xiongsheng) {
            selId = 6;
        } else if (id == R.id.jcses_layout) {
            selId = 7;
        } else if (id == R.id.esbxx_layout) {
            selId = 8;
        } else if (id == R.id.lly_pengzhu) {
            selId = 9;
        }
        Bundle bundle = new Bundle();
        bundle.putString("selId", selId+"");
        bundle.putString("list", JsonUtil.toJson(listModernTextEntities));
        bundle.putString("str", JsonUtil.toJson(listModernTextStr));
        bundle.putString("data", calDay.get(Calendar.YEAR) + "年" + (calDay.get(Calendar.MONTH) + 1) + "月" + calDay.get(Calendar.DATE) + "日");
        ARouter.getInstance().build(RouterConfig.ROUTER_ACTIVITY_WEATHER_NL_MODERN).with(bundle).navigation();
    }



    @Override
    public void onCalendarOutOfRange(com.haibin.calendarview.Calendar calendar) {

    }

    @Override
    public void onCalendarSelect(com.haibin.calendarview.Calendar calendar, boolean isClick) {
        try {
            if(calDay!=null){
                calDay.set(Calendar.YEAR, calendar.getYear());
                calDay.set(Calendar.MONTH, calendar.getMonth() - 1);
                calDay.set(Calendar.DAY_OF_MONTH, calendar.getDay());
            }
            setlunarDate(calDay);
            getYiJiData(calDay);
          //  getYiJiDataServer(calDay);
            requestCalendar();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void showSelectDate(int year, int month, int day) {
        dataBinding.calendarView.scrollToCalendar(year, month, day);
    }
}
